<template>
    <div class="splist">
        <el-form :inline="true" size="large">
            <inp label="分类编号: "></inp>
            <inp label="分类名称: "></inp>
            <but />
        </el-form>
        <tab :head="header1" :foo="tabelsj2"  >
            <Dialog> + 发布商品</Dialog>
            <!-- tabel按钮 -->
            <template #but="butPorps"  >
                <Dialog  @subadd="Change(butPorps,onlyId)"  >修改</Dialog>
                <el-button @click="shanChu(butPorps,onlyId)" :id="butPorps.text.id" >删除</el-button>
            </template>
        </tab>
    </div>
</template>
<script setup>
import { onMounted, computed,reactive,provide,ref } from "vue"
import { useCounterStore } from "@/pinia/index.js"
import { res } from "@/unit/index.js"
import { onlyId } from "../../commonjs/router-tabel-id"
import { loading,Delete,xiugai } from "../../commonjs/index.js"
const store = useCounterStore()

//localstorage数据
const splist = JSON.parse(localStorage.getItem(onlyId.value))
//渲染dom数据
const tabelsj2 = ref([])


provide("csstable","margin:15px")
onMounted(()=>{
    store.$patch({
        formListName: header1,  
    })
    store.$state.formmodel = { number: "", name: "", same: ""}
       //初始化dom数据
       const sj =  loading(onlyId.value).then(data=>{
        tabelsj2.value = data
    })
})



function shanChu(sj,onlyid){
    Delete(sj, onlyid)
        .then(data => {
            tabelsj2.value = data
        })
}

function Change(e,id){
    xiugai(e,id)
    .then(data => {
            tabelsj2.value = data
        })
}


//添加表格数据
const piniaADD = computed(()=>{
    return store.spform
})

const header1 = [{ key: 'number', name: "品牌编号" }, { key: 'name', name: "品牌名称" }, { key: "same", name: "排序" }]
</script>
